module.exports = class cateDao extends require('../model/cateModel') {
    //查询分类数据
    // static async findCateList(req,res) {
    //     const list = await this.findCateListByCond(req,res)
    //     res.send({ status: 1, message: 'ok', successMessage: list})
    // }
    // 查询分类数据
    static async findCateList(req, res) {
        try {
            const list = await this.findCateListByCond(req, res);
            res.status(200).send({ status: 1, message: 'ok', data: list });
        } catch (error) {
            console.error(error);
            res.status(500).send({ status: 0, message: 'id和分类名冲突！' });
        }
    }

    // 添加分类数据
    static async addCate(req, res) {
        try {
            await this.addCateList(req, res);
            res.send({ status: 1, message: 'ok' });
        } catch (error) {
            console.error(error);
            res.status(500).send({ status: 0, message: '新增失败！' });
        }
    }

    // 修改分类数据
    static async updateCate(req, res) {
        try {
            await this.updateCateList(req, res);
            res.send({ status: 1, message: 'ok' });
        } catch (error) {
            console.error(error);
            res.status(500).send({ status: 0, message: '修改失败！' });
        }
    }
    // 删除分类数据
    static async deleteCate(req, res) {
        try {
            await this.deleteCateList(req, res);
            res.send({ status: 1, message: 'ok' });
        } catch (error) {
            console.error(error);
            res.status(500).send({ status: 0, message: '删除失败！' });
        }
    }
}